package boot.service.impl.wenchuang;

import boot.dao.GoodsMapper;
import boot.dao.WenchuangMapper;
import boot.domain.wenchuang.Wenchuang;
import boot.domain.wenchuang.WenchuangExample;
import boot.domain.wxGoods.Goods;
import boot.domain.wxGoods.GoodsExample;
import boot.service.wenchuangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class wenchuangServiceImpl implements wenchuangService {
    @Autowired
    private WenchuangMapper wenchuangMapper;
    @Override
    public boolean addWenchuang(Wenchuang wenchuang) {
        try {
            wenchuangMapper.insert(wenchuang);
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
        return true;
    }

    @Override
    public List<Wenchuang> getAllWenchuang() {
        WenchuangExample wenchuangExample = new WenchuangExample();
        WenchuangExample.Criteria criteria = wenchuangExample.createCriteria();
        criteria.andIdIsNotNull();
        List<Wenchuang> list = wenchuangMapper.selectByExample(wenchuangExample);
        System.out.println(list);
        return wenchuangMapper.selectByExample(wenchuangExample);
    }

    @Override
    public Wenchuang getWenchuangById(int wenchuangId) {
        WenchuangExample wenchuangExample = new WenchuangExample();
        WenchuangExample.Criteria criteria = wenchuangExample.createCriteria();
        criteria.andIdEqualTo(wenchuangId);
        List<Wenchuang> list = wenchuangMapper.selectByExample(wenchuangExample);
        System.out.println(list);
//        System.out.println(goods);
        return list.get(0);
    }




}
